<?php

session_start();

if (isset($_POST["login"]) && $_POST["login"] != "") {
  $_SESSION["login"] = $_POST["login"];
}
if (isset($_GET["logout"]) && $_GET["logout"] == "true") {
  unset($_SESSION["login"]);
}
?>
<html>
<body>

<form method="POST" action="tp.php">
Inserez votre login <input type="text" name="login"/>
<br /><br />

<input type="submit" value="Login"  />
<br /><br />
<?php 

if (isset($_SESSION["login"])):?>
Bonjour <? echo $_SESSION["login"]?>,<br />  
Le code secret est toto42

<br /><br />
<a href="?logout=true">Se deconnecter</a>
<?php endif ?>
</form>


</body>
</html>